import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';

import '@/assets/css/reset.css'

import 'element-ui/lib/theme-chalk/index.css';

Vue.config.productionTip = false
Vue.use(ElementUI);

router.beforeEach((to, from, next)  => {
  if (to.fullPath === '/login') {
    next()
  } else {
    let token = window.localStorage.getItem('token')
    if (token) {
      next()
    } else {
      next({
        path: '/login'
      })
    }
  }
});

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
